<%
  row_style = ""

  if (release.release_date && release.release_date >= Time.now)
    row_style = "background-color: yellow"
  end
%>
<tr style="<%= h row_style%>">
  <td><%= release.release_number%> </td>
  <td><%= h release.release_date.strftime("%d-%b-%Y") if release.release_date%></td>
  <td><%= h release.bugs.select { |b| b.status.eql?("Done") and b.defect_type.eql?("Defect")}.size  %></td>
  <td><%= h release.bugs.select { |b| b.status.eql?("Done") and b.defect_type.eql?("Change Request")}.size  %></td>

  <%
    review_comments = 0
    qa_failures = 0
    developers = []
    release.bugs.each do |bug|
        review_comments += bug.comments.select { |c| c.comment_type.eql?(Comment::REVIEW)}.size
        qa_failures += bug.comments.select { |c| c.comment_type.eql?(Comment::QA_FAILURE)}.size
        developers << bug.developer.nickname if bug.developer and bug.status.eql?("Done")

    end

    top_contributor = ""
    top_contributor_count = 0
    developers.uniq.each do |ud|
      ud_count = developers.select { |d| d.eql?(ud) }.size
      if  ud_count > top_contributor_count
        top_contributor_count = ud_count
        top_contributor = ud
      end
    end

  %>
  <td><%= h review_comments %></td>
  <td><%= h qa_failures %></td>
  <td><%= h top_contributor %> (<%= h top_contributor_count %>)</td>
</tr>

